package ee.ttu.serge.algo;

import java.math.BigInteger;

public class Fibonacci {

   public static BigInteger recoursive(int n) {
      if (n == 0) return BigInteger.ZERO;
      if (n <= 2) return BigInteger.ONE;
      else return recoursive(n - 1).add(recoursive(n-2));
   }
   
   public static BigInteger recoursive(int n, BigInteger count) {
      count.add(BigInteger.ONE);
      if (n == 0) return count;
      if (n <= 2) return count;
      else return recoursive(n - 1, count).add(recoursive(n-2, count));
   }
   
   public static int interactive(int n) {
      if (n == 0) return 0;
      if ( n <= 2) return 1;
      int[] f = new int[n + 1];
      f[1] = 1;
      f[2] = 1;
      for (int i = 3; i <= n; i++) {
         f[i] = f[i - 1] + f[i - 2];
      }
      return f[n];
   }
   
}
